<template>
    <div class="cart">
        <van-checkbox-group v-model="result">
            <van-checkbox name="a" v-for="item in cartList" :key="item.id" v-model="item.checked">
                <van-swipe-cell style="width: calc(100vw - 28px)">
                    <van-card :num="item.number" :price="item.market_price" :desc="item.goods_specifition_name_value" :title="item.goods_name" class="goods-card"
                        :thumb="item.list_pic_url" />
                    <template #right>
                        <van-button square text="删除" type="danger" class="delete-button" />
                    </template>
                </van-swipe-cell>
            </van-checkbox>
        </van-checkbox-group>

        <van-submit-bar :price="cartTotal.goodsAmount" button-text="提交订单" @submit="onSubmit">
            <van-checkbox v-model="checkedAll">全选</van-checkbox>
            <template #tip>
                你的收货地址不支持同城送
            </template>
        </van-submit-bar>

    </div>
</template>

<script>
import { getCart } from '@/api'
export default {
    data() {
        return ({
            checkedAll: false,
            result: [],
            cartTotal:{},
            cartList:[]
        })
    },
    async mounted() {
        const {
            data: {
                data:{ cartList , cartTotal}
            },
        } = await getCart();
        this.cartList = cartList
        this.cartTotal = cartTotal
        console.log(this.cartList);
    },
    methods: {
        onSubmit() {
            this.$toast('该功能未开放')
        }
    }
}
</script>

<style scoped>
.van-submit-bar {
    bottom: 50px
}

.goods-card {
    margin: 0;
    background-color: #fff;
}

.delete-button {
    height: 100%;
}
</style>